package com.lzp.wechat.service.impl;

import cn.hutool.http.HttpUtil;
import com.lzp.wechat.entity.WeiXinParameter;
import com.lzp.wechat.service.AccessTokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class AccessTokenServiceImpl implements AccessTokenService {

    @Autowired
    private WeiXinParameter weiXinParameter;

    /**
     * 获取access_token
     *
     * @return
     */
    @Override
    public String getAccessToken() {
        String url = weiXinParameter.getAccessTokenUrl();
        String appId = weiXinParameter.getAppId();
        String appSecret = weiXinParameter.getAppSecret();
        url = url.replace("APPID", appId).replace("APPSECRET", appSecret);
        return HttpUtil.get(url);
    }

}
